package com.starview.star.code.repository;

import java.io.File;
import java.io.IOException;

import com.starview.star.compiler.util.FileUtil;
import com.starview.star.compiler.util.PrettyPrintDisplay;

@SuppressWarnings("serial")
public class CodeHash implements CodeTree
{
  private final String hash;
  public static final String HASH = "source$hash";

  public CodeHash(String hash)
  {
    this.hash = hash;
  }

  public String getHash()
  {
    return hash;
  }

  @Override
  public void write(File output) throws IOException
  {
    FileUtil.writeFile(output, hash);
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    disp.appendQuoted(hash);
  }

  @Override
  public String getPath()
  {
    return HASH;
  }

  @Override
  public String getExtension()
  {
    return null;
  }

}
